﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesListEasyUIImport.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.ImortDate.FTradeReceivablesListEasyUIImport" %>

<%--应收账款主表--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../EasyUI/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../../EasyUI/themes/icon.css" />
	<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>   
	<script type="text/javascript" src="../../EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../EasyUI/easyui-formatter_20140718.js"></script>
     <link href="../../themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../../js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>

    <script type="text/javascript">
       
      

        $(document).ready(function () {          
           
           
            //自动完成
            $(".autocomplete").each(function () {
                var $this = $(this);
                var url = unescape($this.attr("autocompletehref"));
                $this.autocomplete(url);
            });
            //加载数据
            InitGird();  
           
            
        })
        //加载列表数据
        function InitGird() {
            $('#tab_list').datagrid({               
                url: location.href, //请求数据的页面
                sortName: 'FTradeID', //排序字段
                sortOrder: 'asc', //排序类型
                idField: 'FTradeID', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
                nowrap: true, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                    {title: '系统ID', field: 'FTradeID', width:50 , sortable: true,formatter:function(value, row, index){
                            if(row.FTradeSalesId>0)
                                return "<b style='color:red;'>"+value+"</b>";
                                return value;
                        }
                    },
                	{ title: '合同号', field: 'HeTongHao', width: 110, sortable: true,formatter:function(value, row, index){
                            if(row.HeTongHao==undefined)
                                return "";
                            return '<a href="#"  title="查看应收帐款明细信息" onclick="onViewClick(\''+row.FTradeID+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    },
                    {title: '销售时间', field: 'XiaoShouShiJian', width: 70,formatter:formatterdate , sortable: true},
                    {title: '经销商', field: 'JingXiaoShang', width: 80 , sortable: true},
                    {title: '机号', field: 'JiHao', width:60 , sortable: true,formatter:function(value, row, index){
                            if(value==undefined)
                                return "";
                            //事件处理
                            return '<a href="#"  title="查看已冲帐明细信息" onclick="onViewBalanceByJiHaoClick(\''+value+'\'); return false;">'+value+'</a>';
                        }
                    },
                    {title: '数量', field: 'ShuLiang', width:50 , sortable: true},
//                    {title: '机器状态', field: 'JiQiState', width: 60, sortable: true,formatter:function(value, row, index){
//                            if(value=="正常")
//                                return "一般销售";
//                            return value;
//                        }
//                     },
				]],
                columns: [[                   
//                    { title: '型号', field: 'XingHao', width: 90, sortable: true},
//                    { title: '单价', field: 'Price', width: 80, sortable: true },
//                    { title: 'GPS费用', field: 'GPSFeiYong', width: 70, sortable: true},
//                    { title: '折让金额', field: 'YueCuXiaoJinE', width: 80, sortable: true },
                    { title: '合同金额', field: 'HeTongJinE', width: 80, sortable: true},
                    { title: '到期日', field: 'DaoQiRi', width: 90, sortable: true },
                    { title: '已收', field: 'YiShouKuanXiang', width: 90, sortable: true},
                    { title: '未收', field: 'WeiShouKuanXiang', width: 90, sortable: true},
//                    { title: '逾期', field: 'YuQiKuanXiang', width: 90, sortable: true},
                    { title: '收款条款', field: 'XiaoShouLeiXing', width: 120, sortable: true},
                    { title: '合同付款条款', field: 'FuKuanTiaoKuan', width: 120, sortable: true},
                    { title: '终端销售状态', field: 'ZDXiaoShouState', width: 90, sortable: true},
                    { title: '终端销售时间', field: 'ZDXiaoShouShiJian', width: 90, sortable: true},
                    { title: '终端用户', field: 'ZDYongHu', width: 90, sortable: true},
                    { title: '维保费', field: 'UpKeepJinE', width: 90, sortable: true}
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "query" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true,
                rowStyler:function(index,row)
                {
                    if(row.JiQiState!="正常")
                        return  "color:red;";  
                }
            });

        }  
       
    </script>
    <script>
        //操作功能JS

        //打开高级查找窗口
        function onAdjSearch() {
            $("#tab_search").dialog("open");
            $("#search-buttons").find("#btn_search").click(function () {
                var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
                query.action = "query";
                $('#tab_list').datagrid("options").queryParams = query;
                $('#tab_list').datagrid('load');
                $("#tab_search").dialog("close");
                return false;
            });
        }
       
        //处理导入数据
        function onImportBtnClick() {
            //var row = $('#tab_list').datagrid('getSelected')
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要处理导入数据');
                return false;
            }
            var FTradeID = row.FTradeID;

            /*判断是否处理过*/
            $.ajax({
                type: 'get',
                url: 'FTradeReceivablesEditImport.aspx?ajaxmethod=canimport&FTradeID=' + encodeURI(FTradeID) ,
                dataType: "text",
                async: true,
                cache: false,
                success: function (json) {
                    try {
                     
                        if ( parseFloat(json)>0) {
                           $.messager.alert('提示', '此记录已添加处理过,无需再处理，请确认');
                        }
                        else
                        { 
                        var rel = "FTradeReceivablesEditImport";
                        var url = "FTradeModel/ImortDate/FTradeReceivablesEditImport.aspx?FTradeID=" + FTradeID;
                        var title = "处理导入数据";
                        var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
                        //top.$.pdialog.open(url, rel, title, options);
                        top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
                        }
                    }
                    catch (e) {
                     
                    }
                }
            });
           
           
            return false;
        }

        
        //查看
        function onViewClick(FTradeID) {
            var rel = "FTradeReceivablesView";
            var url = "FTradeModel/FTradeReceivablesView.aspx?FTradeID=" + FTradeID;
            var title = "查看应收帐款数据";
            var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            //top.$.pdialog.open(url, rel, title, options);
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        function onViewBalanceByJiHaoClick(JiHao) {
            var rel = "ViewBalanceByJiHao";
            var url = "FTradeModel/ViewBalanceByJiHao.aspx?JiHao=" + JiHao;
            var title = "查看[" + JiHao + "]已冲款记录";
            var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
            //top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
       
       

    </script>
</head>
<body style="margin:2px;" >
    <div id="tab_list"></div>
    <div id="tab_toolbar" style="padding:2px;">
       <a href="#" title="高级查找" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="return　onAdjSearch(this);" Permission="">查找</a>

        <a href="#" title="处理导入数据" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="return onImportBtnClick()" Permission="r查看">导入数据</a>

    </div> 

    
     
    <div id="tab_search" title="查询条件" style=" height:250px; width:500px;" class="easyui-dialog" modal="true" closed="true" buttons="#search-buttons">
        <table class="table_search" width="100%" style=" line-height:21px;">
            <tr>
                <td>经销商:</td>
                <td Colspan="3"><input  name="JingXiaoShang"  class="autocomplete" autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" mustMatch="true" swidth="300" showinputid=""/></td>
            </tr>
            <tr>
                <td>合同号:</td>
                <td Colspan="3"><input  name="HeTongHao" value="" /></td>
            </tr>
            <tr>
                <td>机号:</td>
                <td><input  name="JiHao" value="" /></td>
                <td>机器状态:</td>
                <td>
                    <select name="JiQiState">
                        <option value="-" >所有...</option>
                        <option value="正常" selected>一般销售</option>
                        <option value="改分期">改分期</option>
                        <option value="改经销商">改经销商</option>
                        <option value="换机">换机</option>
                        <option value="退机">退机</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    销售时间：
                </td>
                <td Colspan="3">                    
                    从<input name="XiaoShouShiJianFrom" class="easyui-datebox" type="text" value="" />
                    到<input name="XiaoShouShiJianTo" type="text" class="easyui-datebox" value="" />
                </td>
            </tr>
            <tr>
                <td>显示已处理:</td>
                <td colspan="3">
                    <input type="checkbox" name="IsShowImport" value="true"  />
                </td>
            </tr>
        </table>
        <div id="search-buttons">
            <a id="btn_search" href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" plain="true">提交</a> 
            <a href="javascript:;" class="easyui-linkbutton" onclick="$('#tab_search').dialog('close');return false;" iconcls="icon-cancel" plain="true">取消</a>
        </div>
    </div>
</body>
</html>